package com.example.demo20230927;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping("/")
    public String index() {
        return "Hello, World!";
    }

    @Autowired
    private StringRedisTemplate redisTemplate;

    @RequestMapping("/redis")
    public String testRedis() {
        redisTemplate.opsForValue().set("testKey", "123");
        return redisTemplate.opsForValue().get("testKey");
    }
}
